#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int kMaxN = 1020;
const long long kInf = 1e18;

struct Graph {
  int n;
  vector<pair<int, int>> g[kMaxN];
  long long dist[kMaxN];

  void AddEdge(int u, int v, int w) {
    g[u].emplace_back(v, w);
  }

  void Dijkstra(int s) {
    priority_queue<pair<long long, int>> pq;

    fill(dist, dist + n + 1, kInf);
    dist[s] = 0;
    pq.emplace(-dist[s], s);
    while (!pq.empty()) {
      long long d = -pq.top().first;
      int u = pq.top().second;

      pq.pop();
      if (dist[u] != d) {
        continue;
      }
      for (const pair<int, int> &e : g[u]) {
        int v = e.first;

        if (dist[v] > d + e.second) {
          dist[v] = d + e.second;
          pq.emplace(-dist[v], v);
        }
      }
    }
  }
} old_graph, new_graph;

int t[kMaxN], c[kMaxN];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  int b, e;

  cin >> n >> m >> b >> e;
  old_graph.n = new_graph.n = n;
  for (int i = 0; i < m; i++) {
    int u, v, w;

    cin >> u >> v >> w;
    old_graph.AddEdge(u, v, w);
    old_graph.AddEdge(v, u, w);
  }
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> c[i];
  }
  for (int i = 1; i <= n; i++) {
    old_graph.Dijkstra(i);
    for (int j = 1; j <= n; j++) {
      if (i == j) {
        continue;
      }
      if (old_graph.dist[j] <= t[i]) {
        new_graph.AddEdge(i, j, c[i]);
      }
    }
  }

  new_graph.Dijkstra(b);
  if (new_graph.dist[e] == kInf) {
    cout << "-1\n";
  } else {
    cout << new_graph.dist[e] << "\n";
  }
  return 0;
}